package com.easy.mapper;

import com.easy.bean.Schedule;
import com.easy.bean.Train;
import com.easy.bean.TrainRoute;
import com.easy.util.Page;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ScheduleMapper {
    int add(@Param("schedule") Schedule schedule) ;
    int del(@Param("id") Integer id) ;
    int edit(@Param("schedule")  Schedule schedule) ;
    Schedule one(@Param("id") Integer id) ;


    // 查询所有班次的剩余票数
    @MapKey("id")
    Map<Integer, Map<String, Object>> selectAllRemainingSeats();

//    @Select("SELECT id, remain_seats FROM schedule WHERE isdel = 0")
//    @MapKey("id")  // 指定用 "id" 字段作为外层 Map 的 key
//    Map<Integer, Integer> selectAllRemainingSeats();

    // 查询单个班次的剩余票数
    Integer selectRemainingSeats(int id);

    // 更新班次的剩余票数
    int updateRemainingSeats(int id, int newCount);

    //这两个的@Param("param")参数名是要求必须一样的，否则报错
    int pageCount(@Param("param") Schedule schedule) ;
    List<Schedule> page(@Param("page") Page page, @Param("param") Schedule schedule) ;







}
